package il.ac.braude.sona.entities;

import java.io.Serializable;
import java.util.ArrayList;


/**
 * The LoginKit contains all information required on login such as messages, 
 * pending requests, loged user and available information systems 
 *  
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
@SuppressWarnings("serial")
public class LoginKit implements Serializable{
	/**
	 * The loged-in User information 
	 */
	private User user;
	/**
	 * The available information systems
	 */
	private ArrayList<String> systems;
	/**
	 * The messages for user
	 */
	private ArrayList<Messege> mssgs;
	/**
	 * The requests which user need or able to perform action.
	 */
	private ArrayList<ChangeRequest> pendingRequests;
	
	/**
	 * Constructs the LoginKit.
	 * 
	 * @param u
	 *            The loged-in User information 
	 * @param systemsAvailable
	 *            The available information systems
	 * @param mssgs
	 *            The messages for user
	 * @param pending
	 *           The requests which user need or able to perform action
	 */
	public LoginKit(User u, ArrayList<String> systemsAvailable, ArrayList<Messege> mssgs, ArrayList<ChangeRequest> pending) {
		user=u;
		systems=systemsAvailableSelection(systemsAvailable);
		this.setMssgs(mssgs);
		setPendingRequests(pending);
	}
	
	/**
	 * Getter for User field
	 * @return user - The loged-in User 
	 */
	public User getUser() {
		return user;
	}
	/**
	 * Setter for User field
	 * @param user - The loged-in User 
	 */
	public void setUser(User user) {
		this.user = user;
	}
	/**
	 * Getter for systems field
	 * @return systems - Array List contains the available systems
	 */
	public ArrayList<String> getSystems() {
		return systems;
	}
	/**
	 * Setter for User field
	 * @param systems - Array List contains the available systems
	 */
	public void setSystems(ArrayList<String> systems) {
		this.systems = systems;
	}
	/**
	 * Getter for mssgs field
	 * @return mssgs - Array List contains the messages for user
	 */
	public ArrayList<Messege> getMssgs() {
		return mssgs;
	}
	/**
	 * Setter for mssgs field
	 * @param mssgs - Array List contains the messages for user
	 */
	public void setMssgs(ArrayList<Messege> mssgs) {
		this.mssgs = mssgs;
	}
	/**
	 * Getter for pendingRequests field
	 * @return pendingRequests - Array List contains the pending requests for user
	 */
	public ArrayList<ChangeRequest> getPendingRequests() {
		return pendingRequests;
	}
	/**
	 * Setter for pendingRequests field
	 * @param pendingRequests - Array List contains the pending requests for user
	 */
	public void setPendingRequests(ArrayList<ChangeRequest> pendingRequests) {
		this.pendingRequests = pendingRequests;
	}
	
	/**
	 * removes the information systems that user can not obtain requests for.
	 * 
	 * @param systemsAvailable - Array List contains all available systems
	 * @return systemsAvailable - Array List contains the available systems for user 
	 */
	private ArrayList<String> systemsAvailableSelection(ArrayList<String> systemsAvailable) {
		if (user.getValue("tid").equals("student")){
			systemsAvailable.remove("Lecturer info. station");
			systemsAvailable.remove("Worker info. station");
		}
		else if (user.getValue("tid").equals("lecturer")){
			systemsAvailable.remove("Student info. station");
			systemsAvailable.remove("Worker info. station");
		}
		else {
			systemsAvailable.remove("Student info. station");
			systemsAvailable.remove("Lecturer info. station");
		}
		return systemsAvailable;
	}
	


}
